package com.atnjupt.servlet;
/**
 * @author Wizarder
 * @create 2021-05-30 18:07
 */

import com.atnjupt.bean.Student;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = " SearchStudentServlet", value = "/ SearchStudentServlet")
public class SearchStudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求参数
        //调用sql语句去数据库中查询
        //设置域对象
        List<Student> studentList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {//表示查询到的数据
            studentList.add(new Student(i+1,"student"+(i+1),i+18,"1573260660"+i));
        }
        request.setAttribute("studentKey",studentList);
        //请求与转发到showStudents.jsp中
        request.getRequestDispatcher("/test/showStudents.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
